how to return a function from another function